package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.HelpInfo;
import com.ruoyi.system.mapper.HelpInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.HelpEvaluateMapper;
import com.ruoyi.system.domain.HelpEvaluate;
import com.ruoyi.system.service.IHelpEvaluateService;

/**
 * 帮扶评价Service业务层处理
 *
 * @author ruoyi
 * @date 2023-01-30
 */
@Service
public class HelpEvaluateServiceImpl implements IHelpEvaluateService {
    @Autowired
    private HelpEvaluateMapper helpEvaluateMapper;
    @Autowired
    private HelpInfoMapper helpInfoMapper;

    /**
     * 查询帮扶评价
     *
     * @param id 帮扶评价主键
     * @return 帮扶评价
     */
    @Override
    public HelpEvaluate selectHelpEvaluateById(Long id) {
        return helpEvaluateMapper.selectHelpEvaluateById(id);
    }

    /**
     * 查询帮扶评价列表
     *
     * @param helpEvaluate 帮扶评价
     * @return 帮扶评价
     */
    @Override
    public List<HelpEvaluate> selectHelpEvaluateList(HelpEvaluate helpEvaluate) {
        return helpEvaluateMapper.selectHelpEvaluateList(helpEvaluate);
    }

    /**
     * 新增帮扶评价
     *
     * @param helpEvaluate 帮扶评价
     * @return 结果
     */
    @Override
    public int insertHelpEvaluate(HelpEvaluate helpEvaluate) {
        HelpInfo helpInfo = helpInfoMapper.selectHelpInfoById(helpEvaluate.getStudentId());
        if (helpInfo.getId().equals(helpEvaluate.getStudentId())) {
            return helpEvaluateMapper.insertHelpEvaluate(helpEvaluate);
        }else{
            return 0;
        }
    }

    /**
     * 修改帮扶评价
     *
     * @param helpEvaluate 帮扶评价
     * @return 结果
     */
    @Override
    public int updateHelpEvaluate(HelpEvaluate helpEvaluate) {
        return helpEvaluateMapper.updateHelpEvaluate(helpEvaluate);
    }

    /**
     * 批量删除帮扶评价
     *
     * @param ids 需要删除的帮扶评价主键
     * @return 结果
     */
    @Override
    public int deleteHelpEvaluateByIds(Long[] ids) {
        return helpEvaluateMapper.deleteHelpEvaluateByIds(ids);
    }

    /**
     * 删除帮扶评价信息
     *
     * @param id 帮扶评价主键
     * @return 结果
     */
    @Override
    public int deleteHelpEvaluateById(Long id) {
        return helpEvaluateMapper.deleteHelpEvaluateById(id);
    }

    @Override
    public List<HelpEvaluate> getEvaluateById(Long typeId) {
        return helpEvaluateMapper.getEvaluateById(typeId);
    }
}
